import Vue from 'vue'
import VueRouter from 'vue-router'
// import HomeView from '../views/HomeView.vue'

Vue.use(VueRouter)

const routes = [
    {
        path: '/login',
        name: 'login',
        component: () => import('../components/Login')
    },
    {
        path: '/Index',
        name: 'index',
        component: () => import('../components/Index'),
        children: [
            {
                path: '/Home',
                name: 'home',
                mete: {
                    title: '首页'
                },
                component: () => import('../components/Home')
            },
            {
                path: '/Admin',
                name: 'admin',
                mete: {
                    title: '用户列表'
                },
                component: () => import('../components/admin/AdminManage')
            },
            {
                path: '/User',
                name: 'user',
                meta: {
                    title: '用户管理'
                },
                component: () => import('../components/user/UserManage')
            },
            {
                path: '/Main',
                name: 'main',
                meta: {
                    title: '用户管理'
                },
                component: () => import('../components/Main')
            },
            {
                path: '/BigScreen',
                name: 'bigScreen',
                meta: {
                    title: '大屏展示数据'
                },
                component: () => import('../components/data/BigScreen')
            },
            {
                path: '/WebSocketDemo',
                name: 'webSocketDemo',
                meta: {
                    title: 'websocket页面'
                },
                component: () => import('../components/websocket/WebSocketDemo')
            }

        ]
    }
]

const router = new VueRouter({
    mode: 'history',
    routes
})

const VueRouterPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(to) {
    return VueRouterPush.call(this, to).catch(err => err)
}

export default router
